package TRANVIETHOANG;

import java.util.Scanner;

public class HOMEWORK_04 {

	public static void main(String[] args) {
		String thang, nam;
	
		Scanner in = new Scanner(System.in);
		
		// input and check empty month
		do{
			System.out.println("Nhap thang can xem");
			thang = in.nextLine();
		
			if(thang.isEmpty())
				{
					System.out.println("Ban chua nhap thang");
				}
		}while (thang.isEmpty());
		
		// input and check empty year
		
		do {
			System.out.println("Chon nam can xem");
			nam = in.nextLine();
			if(nam.isEmpty())
			{
				System.out.println("Ban chua nhap thang");
			}
		} while (nam.isEmpty());
		

		
		int mnt = Integer.parseInt(thang);
	    int year = Integer.parseInt(thang);
	    
		if (mnt > 12 || mnt <= 0 || year <= 0) // check if input is valid format
		{
				System.out.println("Wrong Format");
		}
		
		else {
			if (mnt == 4 || mnt == 6 || mnt == 9 || mnt == 11)
		{
			System.out.println("Thang " + mnt + " cua nam " + year + " co 30 ngay");
		} 
	
		else if (mnt == 2)
			
		{
			if ((year%400==0) || (year%4==0 && year%100!=0))
			{
				System.out.println("Thang " + mnt + " cua nam " + year + " co 29 ngay");
			}
			
			else {
				System.out.println("Thang " + mnt + " cua nam " + year + " co 28 ngay");
			}
		}
		else {
			System.out.println("Thang " + mnt + " cua nam " + year + " co 31 ngay");
			
		}
		}
	}
}
